package com.gitee.ice1938.adcode.fun;

import java.util.Calendar;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 */
@Controller
@RequestMapping("/demo/dict")
public class DemoDictController {

	@Autowired
	private DictAdministrativeAreaService dictAdministrativeAreaService;

	/**
	 * 页面
	 */
	@RequestMapping(path = "/cityselect")
	public String index(HttpServletRequest request, HttpServletResponse response, Model model) {
		return "demo/dict/cityselect";
	}

	/**
	 * 数据查询列表
	 */
	@RequestMapping(path = { "/cityselect/json/{year}", "/cityselect/json" })
	@ResponseBody
	public Map<String, Object> json(@PathVariable(value = "year", required = false) Integer year,
	        HttpServletRequest request, HttpServletResponse response) {
		Calendar cl = Calendar.getInstance();
		 year = year==null ?cl.get(Calendar.YEAR):year;
		Map<String, Object> page = dictAdministrativeAreaService.queryForCityselect(year);
		return page;
	}

}
